20230322
[shlib.git] / testing / 6.shlib_v0_4_testing.Testing for shlib v0_4.unit / 2.tmpl_testing.tmpl Testing.unit / scripts / uniq3.shlib
blobca7a87cdb20910e36d891a452d4435e88b171154
1 #!/bin/bash
2 ############################################################
3 # source: uniq3.shlib
4 # author: devenkong(18151155@qq.com)
5 # date: 2021-10-03
6 ############################################################
7 # Copyright (C) 2022- Free Software Foundation, Inc.
8 # This configure script is free software; the Free Software
9 # Foundation gives unlimited permission to copy, distribute
10 # and modify it.
11 ############################################################
12 # note:
13 # this is a test shlib file for nest include testing. env
14 # var and function can work in nest include.
15 ############################################################
19 # todo£º
20 # @
23 dbgout ()
25 echo -ne "$@"
28 dbgout "load uniq3.shlib at the beginning ...\n"
31 # this cmd enable alias feature in script. it is disabled in default.
32 shopt -s expand_aliases
35 # global variable re-init if this shlib has been loaded.
36 # and the code after 'uniqlib' will not be loaded repeatly.
37 # invoke PROG_GVAR_INIT before 'uniqlib'.
38 # if this shlib has not been loaded, uniqlib will not skip
39 # loading code after it.
41 echo -ne "PROG_GVAR_INIT uniq3\n"
42 PROG_GVAR_INIT uniq3.shlib
44 echo -ne "uniqlib uniq3\n"
45 uniqlib uniq3.shlib
47 echo -ne "normal init invoke.\n"
49 ##############################
50 # section: shlib include
51 ##############################
52 . shlibinc
54 #include stdio.shlib
57 ##############################
58 # section: public comment info
59 ##############################
62 ##############################
63 # section: variable define
64 ##############################
66 shlib_uniq3_init ()
68 # global variable init.
69 if [[ ! -v TEST_UNIQ3 ]]; then
70 TEST_UNIQ3=1
71 else
72 TEST_UNIQ3=$(( TEST_UNIQ3 + 1 ))
75 # global exported variable init.
76 if [[ ! -v TEST_INC_CNT ]]; then
77 declare -g -x TEST_INC_CNT=1
78 else
79 TEST_INC_CNT=$(( TEST_INC_CNT + 1 ))
82 dbgout "shlib_uniq3_init() is invoked in uniq3.shlib!\n"
83 dbgout "TEST_UNIQ3 defined in uniq3.shlib is '$TEST_UNIQ3'.\n"
84 dbgout "TEST_INC_CNT defined in uniq.shlib is '$TEST_INC_CNT'.\n"
85 dbgout "TEST_INC_CNT is $TEST_INC_CNT, it is exported by parent process.\n"
88 # this func will be invoke in first inclussion.
89 shlib_uniq3_init
92 # global variable init function invoking.
93 # invoke GVAR_INIT if it is running at first time.
95 #GVAR_INIT uniq3.shlib
98 ##############################
99 # section: private function
100 ##############################
104 ##############################
105 # section: public function
106 ##############################
109 # fsyntax: uniq_test_func3
110 # fdesc: this is a test func for uniq testing.
112 uniq_test_func3 ()
114 dbgout "uniq_test_func3(TEST_UNIQ3=$TEST_UNIQ3, TEST_INC_CNT=$TEST_INC_CNT) is invoked in uniq3.shlib.\n"
117 alias uniq_test_alias3="dbgout \"uniq_test_alias3() is an example in uniq3.shlib.\n\""
120 dbgout "load uniq3.shlib at the tail ...\n"
122 ######################
123 # section: file tail
124 ######################